package top.kaoshanji.p1ch04a;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.text.Collator;
import java.util.Locale;

/**
 * 代码清单 p1ch04a-17：字符串比较时的粒度选择对结果的影响
 * author kaoshanji
 * ^_^
 * create time 2025/1/16 18:39
 */
public class CollatorExample01 {

    private static final Logger logger = LogManager.getLogger(CollatorExample01.class);

    public static void main(String[] args) {
        logger.info("...代码清单 p1ch04a-17：字符串比较时的粒度选择对结果的影响...");

        Collator collator = Collator.getInstance(Locale.US);

        collator.setStrength(Collator.PRIMARY);
        int compare1 = collator.compare("abc", "ABC");
        logger.info("...compare1:{}...", compare1);

        collator.setStrength(Collator.IDENTICAL);
        int compare2 = collator.compare("abc", "ABC");
        logger.info("...compare2:{}...", compare2);

    }

}
